﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using MetroTwitter.External.Twitter;
using System.Diagnostics;

namespace TwitterExample
{
    public partial class MainPage : PhoneApplicationPage
    {
        TwitterClient client;
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            if (String.IsNullOrEmpty(AppKeys.kTwitterAppKey) || String.IsNullOrEmpty(AppKeys.kTwitterAppSecret))
                throw new NotImplementedException("You need to add your keys");

            client = new TwitterClient(AppKeys.kTwitterAppKey, AppKeys.kTwitterAppSecret);
        }
        private void clickMeButton_Click(object sender, RoutedEventArgs e)
        {
            testClient();
        }

        private async void testClient()
        {
            // NOTE: Twitter may not work with this line and your key (you may need to set your own domain)
            var authd = await client.AuthorizeAsync("http://jaykimble.net"); 
            Debug.WriteLine("Authd: " + authd);
            var result = await client.GetAccountTotals();
            Debug.WriteLine("Account Totals: " + result);
        }
    }
}